<!-- BEGIN ACTION TAB -->
<div class="tab-pane" id="action">
  <div class="row">
    <div class='col-md-10 tools-container'>

      <div class="panel call <%= 'disabled' unless CallTool.enabled? %>">
        <div class="panel-heading">
          <% if CallTool.enabled? %>
            <%= f.check_box :enable_call,
                data: {toggle: "collapse", target: "#call-fields"} -%>
            <%= f.label :enable_call -%>
          <% else %>
            <%= f.check_box :enable_call, disabled: true -%>
            <%= link_to "Enable call", "#call-fields", data: { toggle: "collapse" } %>
          <% end %>

          <a class="caret" href="#call-fields" data-toggle="collapse">
            <i class="icon ion-arrow-<%= @actionPage.enable_call ? 'up' : 'down' %>-b"></i> <span class="sr-only">Toggle call panel</span>
          </a>
        </div>

        <div id="call-fields" class="panel-body collapse <%= 'in' if @actionPage.enable_call? -%>">
          <% if !CallTool.enabled? %>
            <p>To enable this tool, deploy an instance of EFF's Call Power application. See the GitHub <%= link_to "repository", "https://github.com/EFForg/call-congress" %> for details.<p>
          <% end %>

          <fieldset<%= ' disabled' unless CallTool.enabled? %>>
            <%= f.fields_for :call_campaign do |t| -%>
              <div class="form-group">
                <%= t.label :title %>
                <%= t.text_field :title %>
              </div>
              <div class="form-group">
                <%= t.label :call_campaign_id, "Campaign" %>
                <%= t.select :call_campaign_id, call_campaign_options_for_select %>
              </div>
              <div class="form-group">
                <%= t.label :call_campaign_id, "What to say" %>
                <div class="epiceditor" id="action-page-what-to-say"></div>
                <%= t.text_area :message, id: "what-to-say",
                                style: "display: #{ CallTool.enabled? ? 'none' : 'block' };" %>
              </div>
            <% end -%>
          </fieldset>
        </div>
      </div><!-- END div.panel.call -->

      <div class="panel petition">
        <div class='panel-heading'>
          <%= f.check_box :enable_petition,
            data: {toggle: 'collapse', target: '#petition-fields'} %>
            <%= f.label :enable_petition %>

          <a class="caret" href="#petition-fields" data-toggle="collapse">
            <i class="icon ion-arrow-<%= @actionPage.enable_petition ? 'up' : 'down' %>-b"></i> <span class="sr-only">Toggle petition panel</span>
          </a>
        </div>
        <div id='petition-fields' class='panel-body collapse <%= 'in' if @actionPage.enable_petition? -%>'>
          <%= f.fields_for :petition do |p| %>
            <%= p.hidden_field :id %>
            <div class="form-group">
              <%= p.label :title %>
              <%= p.text_field :title %>
            </div>
            <div class="form-group">
              <%= p.label :description %>
              <div class="epiceditor" id="epic-petition-description"></div>
              <%= p.text_area :description, :id => 'petition-description', :style => 'display: none;' %>
            </div>
            <div class="form-group">
              <%= p.label :goal %>
              <%= p.text_field :goal %>
            </div>
            <div class="form-group">
              <%= p.check_box :enable_affiliations,
                data: {toggle: 'collapse', target: '#affiliation-settings'} %>
              <%= p.label :enable_affiliations, 'Allow local affiliations <span class=help-text>(ex. Colleges and Universities)</span>'.html_safe -%>
            </div>
            <fieldset id="affiliation-settings" class="target-fields collapse <%= 'in' if @actionPage.enable_petition and @actionPage.petition.enable_affiliations? -%>">
              <% if @actionPage.persisted? %>
                <div>
                  <%= link_to 'Add or edit local institutions', [:admin, @actionPage, Institution], target: :blank -%>
                </div>
                <div>
                  <%= link_to 'Add or edit relationships', [:admin, @actionPage, AffiliationType], target: :blank -%>
                </div>
              <% else %>
                Save the action to add institutions and relationships.
              <% end %>
            </fieldset>
          <% end -%>
         </div>
      </div><!-- END div.panel.petition -->

      <div class="panel tweet">
        <div class='panel-heading'>
          <%= f.check_box :enable_tweet,
            data: {toggle: 'collapse', target: '#tweet-fields'} %>
          <%= f.label :enable_tweet %>

          <a class="caret" href="#tweet-fields" data-toggle="collapse">
            <i class="icon ion-arrow-<%= @actionPage.enable_tweet ? 'up' : 'down' %>-b"></i> <span class="sr-only">Toggle tweet panel</span>
          </a>
        </div>
        <div id='tweet-fields' class='panel-body collapse <%= 'in' if @actionPage.enable_tweet? -%>'>
          <%= f.fields_for :tweet do |t| %>
            <div class="form-group">
              <%= t.label :cta, "Call to Action" %>
              <%= t.text_field :cta %>
            </div>
            <div class="form-group">
              <%= t.label :message %>
              <%= t.text_area :message %>
            </div>
            <div class="form-group">
              <label>Targets</label>
              <fieldset class='target-fields congress'>
                <%= t.label :target_house do %>
                  <%= t.check_box :target_house %> House
                <% end -%>
                <%= t.label :target_senate do %>
                    <%= t.check_box :target_senate %> Senate
                <% end -%>
              </fieldset>
            </div>
            <div class="form-group">
              <fieldset class='target-fields individuals'>
                <label>Individuals:</label>
                <table class='table table-striped'>
                  <thead>
                    <tr>
                      <th>
                        Handle
                      </th>
                      <th>
                        Photo
                        (<a class="photo-specs-popover" href="#"
                          data-container="body"
                          data-toggle="popover"
                          data-title="photo specs"
                          data-html="true"
                          data-trigger="hover"
                          data-placement="auto bottom"
                          data-content="<ul><li>Recommended size: w=200px, h=200px</li><li>Max file size: 100kB</li><ul>">specs</a>)
                      </th>
                      <th>
                        Delete
                      </th>
                    </tr>
                  </thead>
                  <tbody>
                    <%= t.fields_for :tweet_targets do |tt| -%>
                      <tr class='tweet-target'>
                        <td>
                          <%= link_to '@' + tt.object.twitter_id, tt.object.url, target: "_blank" %>
                        </td>
                        <td>
                          <%= tt.hidden_field :image, class: 'image-input', value: '' -%>
                          <%= render 'tweet_target_image', image: tt.object.image -%>
                        </td>
                        <td>
                          <%= tt.check_box :_destroy, class: 'destroy' %>
                        </td>
                      </tr>
                    <% end -%>
                  </tbody>
                </table>
                <%= label_tag :add_targets do -%>
                  Add targets (one per line, without the '@'):
                <% end -%>
                <%= text_area_tag :add_targets %>
              </fieldset>
            </div>
          <% end -%>
        </div>
      </div><!-- END div.panel.panel-info -->

      <div class="panel email">
        <div class='panel-heading'>
          <%= f.check_box :enable_email,
            data: {toggle: 'collapse', target: '#email-fields'} %>
          <%= f.label :enable_email %>

          <a class="caret" href="#email-fields" data-toggle="collapse">
            <i class="icon ion-arrow-<%= @actionPage.enable_email ? 'up' : 'down' %>-b"></i> <span class="sr-only">Toggle email panel</span>
          </a>
        </div>
        <div id='email-fields' class='panel-body collapse <%= 'in' if @actionPage.enable_email? -%>'>

          <%= f.fields_for :email_campaign do |t| %>

            <div class="form-group">
              <%= t.label :subject %>
              <%= t.text_field :subject %>
            </div>
            <div class="form-group">
              <%= t.label :message %>
              <%= t.text_area :message %>
            </div>
            <div class="form-group">
              <label>Targets</label>
              <%= t.text_field :email_addresses, placeholder: "Email addresses (comma separated)" %>
            </div>
          <% end -%><!-- END f.fields_for :email_campaign -->
        </div>
      </div><!-- END div.panel.email -->

      <div class="panel congress-message">
        <div class="panel-heading">
          <%= f.check_box :enable_congress_message,
            data: {toggle: "collapse", target: "#congress-message-fields"} %>
          <%= f.label :enable_congress_message, "Enable Congress message" %>

          <a class="caret" href="#congress-message-fields" data-toggle="collapse">
            <i class="icon ion-arrow-<%= @actionPage.enable_congress_message ? 'up' : 'down' %>-b"></i> <span class="sr-only">Toggle Congress message panel</span>
          </a>
        </div>
        <div id="congress-message-fields" class="panel-body collapse <%= 'in' if @actionPage.enable_congress_message? -%>">

          <%= f.fields_for :congress_message_campaign do |t| %>

            <div class="form-group">
              <%= t.label :subject %>
              <%= t.text_field :subject %>
            </div>
            <div class="form-group">
              <%= t.label :message %>
              <%= t.text_area :message %>
            </div>
            <div class="form-group">
              <label>Targets</label>
              <fieldset class="target-fields congress">
                <%= t.label :target_house do -%>
                  <%= t.check_box :target_house %> House
                <% end -%>
                <%= t.label :target_senate do -%>
                  <%= t.check_box :target_senate %> Senate
                <% end -%>
                <%= t.label :target_specific_legislators do -%>
                  <%= t.check_box :target_specific_legislators %> Specific legislators
                <% end -%>
                <%= t.select :target_bioguide_ids, congress_member_options_for_select(t.object), {}, multiple: true %>
                <div id="congress_message_text_replacement_form_group" class="form-group">
                  <hr>
                  <div class="form-group">
                    <%= t.label :alt_text_email_your_rep do -%>
                      Replace "Email Your Representatives" text with:
                    <% end -%>
                    <%= t.text_field :alt_text_email_your_rep -%>
                  </div>
                    <div class="form-group">
                    <%= t.label :alt_text_look_up_your_rep do -%>
                      Replace "Look Up Your Representatives" text with:
                    <% end -%>
                    <%= t.text_field :alt_text_look_up_your_rep -%>
                  </div>
                  <div class="form-group">
                    <%= t.label :alt_text_extra_fields_explain do -%>
                      Replace extra fields explanation text with:
                    <% end -%>
                    <%= t.text_field :alt_text_extra_fields_explain -%>
                  </div>
                  <div class="form-group">
                    <%= t.label :alt_text_look_up_helper do -%>
                      Replace "look up" helper text with:
                    <% end -%>
                    <%= t.text_field :alt_text_look_up_helper -%>
                  </div>
                  <div class="form-group">
                    <%= t.label :alt_text_customize_message_helper do -%>
                      Replace "customize message" helper text with:
                    <% end -%>
                    <%= t.text_field :alt_text_customize_message_helper -%>
                  </div>
                </div>
              </fieldset>
            </div>
            <div id="topic_category_form_group" class="form-group">
              <%= t.label :topic_category %>
              <%= t.collection_select :topic_category_id, @topic_categories, :id, :name, prompt: true %>
            </div>
            <div id="campaign_tag_form_group" class="form-group">
              <%= t.label :campaign_tag %>
              <%= t.text_field :campaign_tag %>
            </div>

          <% end -%><!-- END f.fields_for :congress_message_campaign -->
        </div>
      </div><!-- END div.panel.congress-message -->

      <div class="panel panel-redirect">
        <div class='panel-heading'>
          <%= f.check_box :enable_redirect,
            data: {toggle: 'collapse', target: '#redirect-fields'} %>
          <%= f.label :enable_redirect %>

          <a class="caret" href="#redirect-fields" data-toggle="collapse">
            <i class="icon ion-arrow-<%= @actionPage.enable_redirect ? 'up' : 'down' %>-b"></i> <span class="sr-only">Toggle redirect panel</span>
          </a>
        </div>
        <div id='redirect-fields' class='panel-body collapse <%= 'in' if @actionPage.enable_redirect? -%>'>
          <div class="form-group">
            <%= f.label :redirect_url %>
            <%= f.text_field :redirect_url %>
          </div>

        </div>
      </div><!-- END div.panel.redirect -->

    </div><!-- END .tools-container -->
  </div>
</div><!-- END .tab-pane -->
<!-- END ACTION TAB -->
